// 控制台状态管理
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 日志类型定义
export interface ConsoleLog {
  type: 'launch' | 'show' | 'hostEventReceive'
  message: string
  timestamp: number
}

export const useConsoleStore = defineStore('console', () => {
  // 日志列表
  const consoleLogs = ref<ConsoleLog[]>([])

  // 添加日志
  function addLog(type: ConsoleLog['type'], message: string) {
    consoleLogs.value.push({
      type,
      message,
      timestamp: Date.now(),
    })
  }

  // 清空日志
  function clearLogs() {
    consoleLogs.value = []
  }

  return {
    consoleLogs,
    addLog,
    clearLogs,
  }
}, {
  persist: true,
})
